package com.jason.cloud.engine.share.driver.project.service;

import com.jason.cloud.engine.share.driver.project.bean.ProjectBean;
import com.jason.cloud.engine.share.driver.project.dao.ProjectDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ProjectServiceImpl implements ProjectService {

    private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class);

    @Resource
    private ProjectDao projectDao;

    /**
     * 列举所有项目
     * @return
     */
    public List<ProjectBean> getProjectLimitByEnterpriseId(int page, int size, String enterpriseId) {
        List<ProjectBean> projectBeanArrayList = new ArrayList<ProjectBean>();
        try {
            projectBeanArrayList = this.projectDao.getProjectLimitByEnterpriseId(page, size, enterpriseId);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
        return projectBeanArrayList;
    }

    /**
     * 计数项目
     * @return
     */
    public int getProjectCountByEnterpriseId(String enterpriseId) {
        int count = 0;
        try {
            count = this.projectDao.getProjectCountByEnterpriseId(enterpriseId);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
        return count;
    }

    /**
     * 保存项目
     * @param projectBean
     */
    public void insertProject(ProjectBean projectBean) {
        try {
            this.projectDao.insertProject(projectBean);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
}
